#include <bits/stdc++.h>

namespace std { // I hate ancient compilers
    template <>
    struct less<void> {
        template <class A, class B>
        auto operator()(const A &a, const B &b) -> decltype(a < b) {
            return a < b;
        }
    };

}

template<class InputIt1, class InputIt2, class OutputIt,
         class Compare = std::less<void>>
OutputIt my_merge(InputIt1 first1, InputIt1 last1,
               InputIt2 first2, InputIt2 last2,
               OutputIt d_first, Compare comp = Compare()) {
    while (first1 != last1 && first2 != last2) {
        if (comp(*first1, *first2)) {
            *(d_first++) = *(first1++);
        } else {
            *(d_first++) = *(first2++);
        }
    }
    return std::copy(first2, last2, std::copy(first1, last1, d_first));
}

template <typename T>
std::vector<T> read_array(std::istream &in=std::cin) {
    int n;
    in >> n;
    std::vector<T> result(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> result[i];
    }
    return result;
}

int main() {
    std::vector<int> a(read_array<int>()), b(read_array<int>());
    std::vector<int> c;
    c.reserve(a.size() + b.size());
    my_merge(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(c));
    std::copy(c.begin(), c.end(), std::ostream_iterator<int>(std::cout, " "));
    std::cout << std::endl;
}
